﻿@{
    Layout = null;
}
<script type="text/javascript">
    function ClearContent()
    {
        document.getElementById("hid_actiontype").value = "add";
 
        document.getElementById("hid_edit_guid").value = "";//清除隐藏域内容
        document.getElementById("txt_Name").value = "";
        document.getElementById("txt_Remark").value = "";
        document.getElementById("txt_Order").value = "1";

    }
    function saveInfo() {
        var rolename = $("#txt_Name").val();
        if (rolename == '') {
            alert("请填写角色名称");
            return;
        }

        var rolemenu = $("#hid_MenuGuid").val();
        if (rolemenu == '') {
            alert("请配置权限");
            return;
        }

        var data = $("#addForm").serializeArray(); //自动将form表单封装成json

        if (document.getElementById("hid_actiontype").value == "edit") {
            //编辑
            $.post("save?actionorder=upd", data, retrunResult, "json");
        }
        else {//添加
            $.post("Save?actionorder=add", data, retrunResult, "json");
        }
        
    }
    function delInfo() {
        var data = $("#searchForm").serializeArray();
        $.post("Del", data, retrunResult, "json");
    }
    function ShowEditMsg() {
        //检测要编辑的项
        var rowscount = 0;
        var cbvalue = "";

        for (i = 0; i < document.forms[0].elements.length; i++) {
            var e = document.forms[0].elements[i];
            if (e.name != "allbox" && e.type == "checkbox") {
                if (e.checked == true) {
                    rowscount = rowscount + 1;
                    cbvalue = e.value;
                }
            }
        }
        if (rowscount!=1)
        {
            alert("请明确选择一个要编辑的部门。");
            return;
        }
        else if(rowscount==1)
        {
            //显示要编辑的内容
            $.post("GetRole", { editguid: cbvalue }, function (result) {
                var jsonresult = (result);
                if (jsonresult.respCode == "200") {
                    document.getElementById("txt_Name").value = jsonresult.data.r_name;
                    document.getElementById("txt_Remark").value = jsonresult.data.r_name;
                    document.getElementById("txt_Order").value = jsonresult.data.r_order;
                    document.getElementById("hid_edit_guid").value = cbvalue;//记录要编辑的内容
                    document.getElementById("hid_actiontype").value = "edit";
             

                }
                else {
                    alert(jsonresult[0].respMsg);
                    return;
                }

            });
            $.post("GetRoleMenuGuidList", { editguid: cbvalue }, function (result) {
                var jsonresult = (result);
                if (jsonresult.respCode == "200") {
                    document.getElementById("hid_MenuGuid").value = jsonresult.data.rmpguid;
                    $("#addDialog").dialog("open");
                }
                else {
                    alert(jsonresult[0].respMsg);
                    return;
                }

            });

            
        }
    }
    function openwindow() {//弹出配置窗口,带用户Guid过去
        //alert(document.getElementById("hid_edit_guid").value)
        openWin("setmenu?rguid=" + document.getElementById("hid_edit_guid").value + "", 400, 500);
    }
</script>
<!-- 部门添加 -->
<div id="addDialog" title="角色添加/编辑">
    <form action="" name="addForm" id="addForm" method="post">
        <div class="kv-item clearfix">
            <label><span class="impInfo">*</span>角色名称：</label>
            <div class="kv-item-content">
                <input type="text" name="txt_Name" id="txt_Name" placeholder="角色名称" />
                <input type="hidden" name="hid_edit_guid" id="hid_edit_guid" value="@ViewBag.NewGuid" />
                <input type="hidden"  name="hid_actiontype" id="hid_actiontype" value="" />
            </div>
        </div>
        <div class="kv-item clearfix">
            <label><span class="impInfo">&nbsp;</span>权限配置：</label>
            <div class="kv-item-content" style="margin-top:5px;">
                <input type="button" id="but_showdep" name="but_showdep" onclick="openwindow()" value="权限配置" />
                <input id="hid_MenuGuid" name="hid_MenuGuid" value="" type="hidden" />

            </div>
        </div>
        <div class="kv-item clearfix">
            <label><span class="impInfo">&nbsp;</span>备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：</label>
            <div class="kv-item-content">
                
                <textarea name="txt_Remark" id="txt_Remark" placeholder="备注"></textarea>
            </div>
        </div>
        <div class="kv-item clearfix">
            <label><span class="impInfo">*</span>权限权重：</label>
            <div class="kv-item-content">
                <input type="text" name="txt_Order" id="txt_Order" value="1" placeholder="权重" />
            </div>
        </div>
        <div style="text-align:center">
            <img src="/common/images/load.gif" alt="加载中..." class="load_data" style="display:none" width="30" height="30" />
        </div>
    </form>
</div>



<!-- 角色删除 -->
<div id="delDialog" title="记录删除">
    <p>你确定要删除选中的记录？</p>
    <div style="text-align:center">
        <img src="/common/images/load.gif" alt="加载中..." class="load_data" style="display:none" width="30" height="30" />
    </div>
</div>
